﻿using Power.Models;
using Power.View.Report;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace Power.ViewModel.Report
{
    /// <summary>
    /// 综合表
    /// </summary>
    public class ComprehensiveTableViewModel: ReportTableBase
    {
        public SummaryTableData Data { get; set; }
        private ComprehensiveTable model;
        public ComprehensiveTableViewModel(ComprehensiveTable model)
        {
            this.model = model;
            Data = new SummaryTableData()
            {
                DefectPipNum = 1,
                ProjectNum = 2,
                PipeNum = 3,
                DetectLen = 4,
            };
            Init();
        }


        public void Init()
        {
            Row = 5;
            Column = 12;
            var table = this.model.table;

            for (int i = 0; i < Row; i++)
            {
                table.RowDefinitions.Add(new RowDefinition() { Height = new GridLength(50) });

            }
            for (int i = 0; i < Column; i++)
            {
                table.ColumnDefinitions.Add(new ColumnDefinition() { Width = new GridLength(100) });
            }

            for (int i = 0; i < Row; i++)
            {
                for (int j = 0; j < Column; j++)
                {
                    DrawColumnSpanCell(table, i, j, "综合表", Column, 0, 0);

                    DrawRowSpanCell(table, i, j, "工点数量", 2, 1, 0);
                    DrawRowSpanCell(table, i, j, "管段数量", 2, 1, 1);
                    DrawRowSpanCell(table, i, j, "检测长度", 2, 1, 2);
                    DrawRowSpanCell(table, i, j, "缺陷管段", 2, 1, 3);

                    DrawColumnSpanCell(table, i, j, "结构性缺陷", 4, 1, 4);
                    DrawColumnSpanCell(table, i, j, "功能性缺陷", 4, 1, 8);

                    DrawCell(table, i, j, "1级", 2, 4);
                    DrawCell(table, i, j, "2级", 2, 5);
                    DrawCell(table, i, j, "3级", 2, 6);
                    DrawCell(table, i, j, "4级", 2, 7);

                    DrawCell(table, i, j, "1级", 2, 8);
                    DrawCell(table, i, j, "2级", 2, 9);
                    DrawCell(table, i, j, "3级", 2, 10);
                    DrawCell(table, i, j, "4级", 2, 11);

                    DrawCell(table, i, j, "个", 3, 0);
                    DrawCell(table, i, j, "段", 3, 1);
                    DrawCell(table, i, j, "m", 3, 2);
                    DrawCell(table, i, j, "段", 3, 3);

                    DrawColumnSpanCell(table, i, j, "处", 8, 3, 4);

                    DrawCell(table, i, j, Data.ProjectNum.ToString(), 4, 0);
                    DrawCell(table, i, j, Data.PipeNum.ToString(), 4, 1);
                    DrawCell(table, i, j, Data.DetectLen.ToString(), 4, 2);
                    DrawCell(table, i, j, Data.DefectPipNum.ToString(), 4, 3);

                    DrawCell(table, i, j, Data.StruLv1.ToString(), 4, 4);
                    DrawCell(table, i, j, Data.StruLv2.ToString(), 4, 5);
                    DrawCell(table, i, j, Data.StruLv3.ToString(), 4, 6);
                    DrawCell(table, i, j, Data.StruLv4.ToString(), 4, 7);

                    DrawCell(table, i, j, Data.FuncLv1.ToString(), 4, 8);
                    DrawCell(table, i, j, Data.FuncLv2.ToString(), 4, 9);
                    DrawCell(table, i, j, Data.FuncLv3.ToString(), 4, 10);
                    DrawCell(table, i, j, Data.FuncLv4.ToString(), 4, 11);
                }
            }
            
            //补边框
            DrawBorder(table);
        }
    }
}
